<template>
  <div>
      <city-header></city-header>
      <city-search :citys="city"></city-search>
      <city-list :hotcity="hotCity" :city="city" :letter="letter"></city-list>
      <city-alphabet :citis="city" @change="handleLetterChange"></city-alphabet>
  </div>
</template>
<script>
import axios from 'axios'
import CityHeader from './components/Header'
import CitySearch from './components/Search'
import CityList from './components/List'
import CityAlphabet from './components/Alphabet'

export default {
  name: 'City',
  data () {
    return {
      hotCity: [],
      city: [],
      letter: ''
    }
  },
  components: {
    CityHeader,
    CitySearch,
    CityList,
    CityAlphabet
  },
  methods: {
    getCityIofo () {
      axios.get('/api/city.json')
        .then(this.handleGetCityIofoSucc)
    },
    handleGetCityIofoSucc (res) {
      this.hotCity = res.data.hotcity
      this.city = res.data.city
    },
    handleLetterChange (letter) {
      this.letter = letter
    }
  },
  mounted () {
    this.getCityIofo()
  }
}
</script>
<style lang="stylus" scoped>
</style>
